package com.yangmy.cobweb.common.core.utils;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author YangMingYang
 * @since 2022/10/23
 */
@Slf4j
public class AsyncBusinessUtils {

    private static final ThreadPoolExecutor executor=new ThreadPoolExecutor(20,50,
            30, TimeUnit.MINUTES,new LinkedBlockingQueue<>());

    public static void execute(Runnable runnable){
        executor.execute(()->{
            try {
                runnable.run();
            }catch (Exception e){
                log.error("异步任务执行异常",e);
            }
        });
    }
}
